#ifndef __DRV_UART_H__
#define __DRV_UART_H__

#ifdef __cplusplus
extern "C" {
#endif

/*=============================Include========================================*/
#if defined(USE_HAL_STM32F4)
#include "stm32f4xx_hal.h"
#endif
/*==============================ExportedMacros================================*/
// 缓冲区字节长度
#define UART_BUFFER_SIZE 256
/*=============================ExportedTypes==================================*/
typedef void (*uart_call_back)(uint8_t *buffer, uint16_t length);

typedef struct uart_manager {
	UART_HandleTypeDef *huart;
	uint8_t tx_buffer[UART_BUFFER_SIZE];
	uint8_t rx_buffer[UART_BUFFER_SIZE];
	uint16_t rx_buffer_size;
	uart_call_back call_back_function;
} uart_manager_t;
/*=============================ExportedDefinitions============================*/
extern UART_HandleTypeDef huart1;
extern UART_HandleTypeDef huart3;
extern UART_HandleTypeDef huart6;

extern uart_manager_t uart1_manager;
extern uart_manager_t uart2_manager;
extern uart_manager_t uart3_manager;
extern uart_manager_t uart4_manager;
extern uart_manager_t uart5_manager;
extern uart_manager_t uart6_manager;
/*=============================ExportedFunctionDeclarations===================*/
void uart_init(UART_HandleTypeDef *huart, uart_call_back call_back_function,
               uint16_t rx_buffer_size);
uint8_t uart_send_data(UART_HandleTypeDef *huart, uint8_t *data,
                       uint16_t length);
uint8_t uart_send_data_dma(UART_HandleTypeDef *huart, uint8_t *data,
                           uint16_t length);
#ifdef __cplusplus
}
#endif

#endif

/*========================COPYRIGHT(C) CCUT-DAMOCLES==========================*/
